package com.huangpeng.designmodel.responsibility;

import com.huangpeng.utils.ReflectionUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * @Author huangpeng
 * @Title 处理者容器
 * @Package
 * @Date 2020/10/21 14:27
 * @Description 处理者容器
 * @Version 1.0
 */
public class ReceiptHandlerContainer {
    public ReceiptHandlerContainer() {
    }
    public static List<IReceiptHandler> getReceiptHandlerList(){
        List<IReceiptHandler> receiptHandlerList = new ArrayList<>();
        //获取ReceiptHandler的实现类
        Set<Class<?>> classLists = ReflectionUtil.getClassSetBySuper(IReceiptHandler.class);
        if(classLists != null && !classLists.isEmpty()){
            classLists.forEach(s -> {
                try {
                    receiptHandlerList.add((IReceiptHandler) s.newInstance());
                }catch (Exception e){
                    e.printStackTrace();
                }
            });
        }
        /*receiptHandlerList.add(new Mt2101ReceiptHandler());
        receiptHandlerList.add(new SurtaxReceiptHandler());
        receiptHandlerList.add(new PersonalIncomeTaxReceiptHandler());
        receiptHandlerList.add(new ValueAddedTaxReceiptHandler());*/

        return receiptHandlerList;
    }
}
